Learn R Programming

hablar (version 0.1.0)

wrapper - s and summary funs: Combine aggregate function and s

Description

[summary function_*] functions are simple wrappers of aggregate function and the s function. s removes all non-values, i.e. NA,Inf,NaN from a vector. However, if the length is 0 it returns NA. The result is then passed to the corresponding aggregation function. For example, min_(x) is identical to min(s(x)). Please read vignette("s") for more information.

Usage

sum_(..., ignore_na = TRUE)

mean_(..., ignore_na = TRUE)

max_(..., ignore_na = TRUE)

min_(..., ignore_na = TRUE)

first_(..., ignore_na = TRUE)

min_(..., ignore_na = TRUE)

sum_(..., ignore_na = TRUE)

mean_(..., ignore_na = TRUE)

first_(..., ignore_na = TRUE)

Arguments

...

one or more vectors

ignore_na

if false missing values are not omitted.

Value

a single aggregated value

Examples

Run this code
# NOT RUN {
## sum_ on non-rational numeric vector
vector <- c(7, NaN, -Inf, 4)
sum_(vector)

## Min of vector with length 0
vector <- c()
# With a wrapped s
min_(vector)

## Max of vector with only NA
# With a wrapped s
max_(vector)

## Use of s when NA should not be removes
vector <- c(7, Inf, NA, 4)
# With a wrapped s
sum_(vector, ignore_na = FALSE)

# }

Run the code above in your browser using DataLab